package pearson.automation.forms.registration;

import org.openqa.selenium.By;
import org.testng.Assert;

import framework.BaseForm;
import framework.Browser;
import framework.elements.Button;
import framework.elements.Label;

public class RegisterStartForm extends BaseForm {
    private static Button agree = new Button(By.cssSelector("img[alt='Log In']"),
            "I Accept");
    private Label introduction = new Label(By.id("introduction"),
            "Introduction");
    private Label privacy = new Label(By.id("privacy"),
            "Introduction");
    private Label licenseAgreement = new Label(By.id("license"),
            "Introduction");
    private String registerURL = Browser.props.getProperty("registerURL").trim().toLowerCase(); 

    public RegisterStartForm() {
        super(agree.getLocator(), "Licence Agreement");
        Assert.assertTrue(browser.getDriver().getCurrentUrl().toLowerCase().contains(registerURL), "Register URL is wrong");
        introduction.assertIsPresent();
        Assert.assertTrue(introduction.getText().length() > 20, "Introduction message is too short");
        privacy.assertIsPresent();
        licenseAgreement.assertIsPresent();
    }
    
    public AccessInformationForm clickAccept() {
            info("Accepting license agreement for the user's registration");
        agree.clickAndWait();
        return new AccessInformationForm();
    }

}
